package com.sqly.doc;

import java.util.ArrayList;
import java.util.List;

import android.app.Fragment;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Window;

import com.sqly.doc.view.AbBottomTabView;


public class MainActivity extends FragmentActivity {
	private AbBottomTabView mBottomTabView;
	private List<Drawable> tabDrawables = null;
	sy_fragment sy;
//	wz_fragment wz;
//	sq_fragment qy;
	qy_fragment qy;
	wd_fragment wd;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE); // 注意顺序
		setContentView(R.layout.activity_main);
		mBottomTabView = (AbBottomTabView) findViewById(R.id.mBottomTabView);

		mBottomTabView.getViewPager().setOffscreenPageLimit(5);
		sy = new sy_fragment();
//		wz = new wz_fragment();
//		qy = new sq_fragment();
		qy = new qy_fragment();
		// fragment_secont page2 = new fragment_secont();
		wd = new wd_fragment();
		List<Fragment> mFragments = new ArrayList<Fragment>();
		mFragments.add(sy);
//		mFragments.add(wz);
		mFragments.add(qy);
		mFragments.add(wd);
		List<String> tabTexts = new ArrayList<String>();
		tabTexts.add("首页");
//		 tabTexts.add("问诊");
		tabTexts.add("签约");
		tabTexts.add("我的");
		mBottomTabView.setTabTextColor(Color.parseColor("#8a8a8a"));
		mBottomTabView.setTabSelectColor(Color.parseColor("#008B8B"));
		// mBottomTabView.setTabBackgroundResource(R.drawable.tab_bg2);
		mBottomTabView.setTabBackgroundColor(Color.WHITE);
		// mBottomTabView.setTabLayoutBackgroundResource(R.drawable.tablayout_bg2);

		tabDrawables = new ArrayList<Drawable>();
		tabDrawables.add(this.getResources().getDrawable(R.drawable.sy1));
		tabDrawables.add(this.getResources().getDrawable(R.drawable.sy2));
//		tabDrawables.add(this.getResources().getDrawable(R.drawable.wz1));
//		tabDrawables.add(this.getResources().getDrawable(R.drawable.wz2));
		// tabDrawables.add(this.getResources()
		// .getDrawable(R.drawable.peican_nomal));
		// tabDrawables.add(this.getResources().getDrawable(
		// R.drawable.peican_click));
		tabDrawables.add(this.getResources().getDrawable(R.drawable.sq1));
		tabDrawables.add(this.getResources().getDrawable(R.drawable.sq2));
		tabDrawables.add(this.getResources().getDrawable(R.drawable.wd1));
		tabDrawables.add(this.getResources().getDrawable(R.drawable.wd2));
		// ��ʾ����һ��
		mBottomTabView.addItemViews(tabTexts, mFragments, tabDrawables);
		mBottomTabView.setTabPadding(2, 2, 2, 2);

		//启动Android定时器，并且启动服务
//		TimerService.getConnet(this);
	}

	@Override
	protected void onDestroy() {
		//停止由AlarmManager启动的循环
//		TimerService.stop(this);
//		//停止由服务启动的循环
//		Intent intent = new Intent(this, TimerService.class);
//		intent.putExtra("flags",3);
//		stopService(intent);
		super.onDestroy();
	}

}
